package cn.myframe.task.init;

import java.util.List;

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import cn.myframe.entity.sys.SysParameterEntity;
import cn.myframe.redis.RedisService;
import cn.myframe.service.sys.SysParameterService;

/**
 * 初始化系统参数压入redis
 * @author Administrator
 *
 */
@Component
public class InitTask {

	@Autowired
	private SysParameterService sysParameterService;
	
	@Autowired
	private RedisService redisService;
	
	@PostConstruct
	public void initParameter(){
		List<SysParameterEntity> list = sysParameterService.queryList(null);
		if(list != null && list.size() > 0){
			String key = "syspara:";
			for(SysParameterEntity entity : list){
				String hashKey = entity.getParamKey();
				String value = entity.getParamValue();
				redisService.hmSet(key, hashKey, value);
				redisService.convertAndSend("dealParameterCache", hashKey);
			}
		}
	}
}
